#pragma once

#include "context/PresentationContext.h"
#include "IPresentationWorkflow.h"
#include "IPresentationRuntime.h"

class AbstractPresentationWorkflow : public IPresentationWorkflow
{
public:
	BEGIN_DEFINE_CLASS(CLASSID_NULL)
		DEFINE_INTERFACE_ENTRY(IPresentationWorkflow)
	END_DEFINE_CLASS()

public:
	AbstractPresentationWorkflow()
	{};
	virtual ~AbstractPresentationWorkflow(){};

	virtual void Prepare(PresentationContext& context) = 0;
	virtual void Present(PresentationContext& context)
	{
		RunPresentation(context);
		FinishPresentation(context);
	}
	virtual void SetKind(const String& kind){m_kind = kind;}
	virtual const String& GetKind() const{return m_kind;}

protected:
	virtual void RunPresentation(PresentationContext& context) = 0;
	virtual void FinishPresentation(PresentationContext& /*context*/){}

protected:
	IPresentationRuntime* GetPresentationRuntime() const;

private:
	String m_kind;
};

//////////////////////////////////////////////////////////////////////////
//inline methods
inline
IPresentationRuntime* AbstractPresentationWorkflow::GetPresentationRuntime() const
{
	sys::ObjectPtr objPresentationRuntime;
	objPresentationRuntime.CreateObject(CLSID_PresentationRuntime);
	sys::InterfacePtr<IPresentationRuntime> pIFPresentationRuntime(objPresentationRuntime);
	return pIFPresentationRuntime;
}